<template>
   <el-form :rule="rules" :inline="true" :model="formInline" class="demo-form-inline">
     <el-form-item label="账号" prop="user">
       <el-input v-model="formInline.user" placeholder="请输入账号" />
     </el-form-item>
     <el-form-item label="密码">
      <el-input type="password" v-model="formInline.password" placeholder="请输入密码"></el-input>
     </el-form-item>
     <el-form-item>
       <el-button type="primary" @click="onSubmit">登录</el-button>
     </el-form-item>
   </el-form>
</template>
 
 <script setup>
 import { reactive } from 'vue'
 import { useRouter } from 'vue-router'

 const router = useRouter()

 const formInline = reactive({
   user: '',
   password: '',
 })
 
 const rules = reactive({
   user: [
      {
         required: true,
         message: "账号不能为空！",
         type: String
      }
   ]
 })

 const onSubmit = () => {
   localStorage.setItem('token', 1);
   router.push('/index');
 }
 </script>
 
